<template>
  <div class="cart">
    <GoodsTable :tableData="data" @spl="remove" />
  </div>
</template>

<script>
import GoodsTable from "./CartTable";
export default {
  name: "Cart",
  data() {
    return {
      data: [],
    };
  },
  computed: {},
  watch: {},

  methods: {
    remove(id) {
      // console.log(id, "好几万吊牌");
      let index = this.data.findIndex((item) => {
        return item._id == id;
      });
      this.data.splice(index, 1);
    },
  },
  created() {
    /* let cart = this.$store.state.user.cart;
    console.log(this.$store.state.user.cart); */
    this.axios
      .get("/api/v1/cart")
      .then((res) => {
        console.log(res);
        this.data = res.data;
      });
  },
  mounted() {},
  components: { GoodsTable },
};
</script>
<style scoped>
</style>